package app.form.component;

public class Text extends AbstractComponent {
    private float minValue, maxValue;
    public Text (String name, String title, float minValue, float maxValue) {
        this.name = name;
        this.title = title;
        this.minValue = minValue;
        this.maxValue = maxValue;
    }
    @Override
    public String renderHTML () {
        StringBuilder s = new StringBuilder ();
        s.append ("<div class='text' id='" + getName() + "'>");
        s.append (getTitleHTML());
        s.append ("<input type='text' name='" + getName() + "' />");
        s.append ("</div>");
        return s.toString();
    }
    @Override
    public String renderCSS () {
        return ".text {"
                    + "padding-top: 5px;"
                    + "padding-bottom: 5px;"
                + "} ";
    }
    @Override
    public String renderJS() {
        return "function "+getName()+"_value() { return textValue('"+getName()+"', "+minValue+", "+maxValue+"); }\r\n";
    }
}
